package com.pks.datacenter.entity.basic;

import java.util.HashMap;
import java.util.Map;

import lombok.Data;
import lombok.EqualsAndHashCode;

import com.pks.util.coder.database.DBField;
import com.pks.util.coder.database.DBQuery;
import com.pks.util.coder.database.DBTable;
import com.pks.web.mybatis.entity.BasicEntity;

/**
 * 
 * @author pks
 * @version 2019年9月10日 
 */
@Data
@EqualsAndHashCode(callSuper = true)
@DBTable(tags = "数据源信息" )
public class DbInfo extends BasicEntity {

	private static final long serialVersionUID = 8876464170616689322L;
	
	/** MYSQL数据库 */
	public static final int db_type_mysql = 1;
	/** SQLSERVER数据库 */
	public static final int db_type_sqlserver = 2;
	/** ORACLE数据库 */
	public static final int db_type_oracle = 3;
	/** HTTP类型 */
	public static final int db_type_http = 4;
	
	/** 本地json文本 */
	public static final int db_type_jsontxt = 5;
	/** 本地json文本zip包 */
	public static final int db_type_jsontxt_zip = 6;
	/** 本地excel*/
	public static final int db_type_excel = 7; 
	/** 排序字段类型 - 数值 */
	public static final int field_type_number = 1;
	/** 排序字段类型 - 时间格式 yyyy-MM-dd HH:mm:ss */
	public static final int field_type_time = 2;
	
	/** 鉴权类型 - HTTP接口 */
	public static final int AUTH_TYPE_HTTP = 1;
	//中间参数  2 开始的值 预留
	/** 鉴权类型 - 固定参数值*/
	public static final int AUTH_TYPE_VALUE =  99;
	
	public static final Map<Integer, String> DB_TYPE_MAP = new HashMap<Integer, String>();
	public static final Map<Integer, String> AUTH_TYPE_MAP = new HashMap<Integer, String>();
	static{
		DB_TYPE_MAP.put(db_type_mysql, "MYSQL数据库");
		DB_TYPE_MAP.put(db_type_sqlserver, "SQLSERVER数据库");
		DB_TYPE_MAP.put(db_type_oracle, "ORACLE数据库");
		DB_TYPE_MAP.put(db_type_http, "HTTP接口");
//		DB_TYPE_MAP.put(db_type_jsontxt, "本地json文本");
//		DB_TYPE_MAP.put(db_type_jsontxt_zip, "本地json文本zip包");
//		DB_TYPE_MAP.put(db_type_excel, "本地EXCEL");
		
		AUTH_TYPE_MAP.put(AUTH_TYPE_HTTP, "HTTP接口获取");
		AUTH_TYPE_MAP.put(AUTH_TYPE_VALUE, "固定参数值");
	}
	
	@DBQuery(value = {"=" })
	@DBField(comment = "所属标签" )
	private Long tagId ; 			
	
	@DBQuery(value = {"=" , "like"})
	@DBField(comment = "数据表名称" , length = 100)
	private String name ; 			
	
	@DBQuery
	@DBField(comment = "数据源类型 1-MYSQL  2-SQLSERVER 3-ORACLE 4-HTTP接口 5-JSON文本 6-多个JSON文本的压缩包 " , length = 4)
	private Integer db_type;
	
	@DBQuery(value = {"=", "in"})
	@DBField(comment = "数据源ID")
	private Long dbSourceId;
	
//	@DBQuery(value = {"=" , "like"})
//	@DBField(comment = "数据库IP" , length = 100)
//	private String db_ip;
//	
//	@DBField(comment = "数据库端口号" , length = 11)
//	private Integer db_port;
//	
//	@DBQuery(value = {"=" , "like"})
//	@DBField(comment = "数据库库名" , length = 100)
//	private String db_name;
//
//	@DBQuery(value = {"=" , "like"})
//	@DBField(comment = "数据库账号" , length = 100)
//	private String db_account;
//	
//	@DBField(comment = "数据库密码" , length = 100)
//	private String db_password;

	@DBQuery(value = {"=" , "like"})
	@DBField(comment = "数据库表名" ,length = 100)
	private String table_name;
	
	@DBField(comment = "数据库查询语句，默认单表查询所有字段" , length = 5000)
	private String db_sql;

	
	@DBQuery(value = {"=" , "like"})
	@DBField(comment = "HTTP接口地址" , length = 200)
	private String http_url;
	
	@DBField(comment = "接口取值参数" , length = 200)
	private String http_value_param;
	
	@DBField(comment = "接口获取成功标识 格式 xx.xx=1" , length = 200)
	private String http_success_flag;
	
	// 接口地址鉴权
	@DBField(comment = "鉴权类型  1-HTTP接口  99-固定鉴权值" , length = 4)
	private Integer auth_type;
	
	@DBField(comment = "鉴权地址：有则填，无则空" , length = 200)
	private String auth_url;
	
	@DBField(comment = "鉴权参数名" ,length = 200)
	private String auth_param;
	
	@DBField(comment = "鉴权参数值有效时间  (单位：秒)  当为-1 的时候无限制 " , length = 11)
	private Long auth_valid_time;
	
	@DBField(comment = "鉴权参数值，如为固定则写死，如为通过接口获取，则为接口返回对象参数，多层的可使用a.b的格式" , length = 100)
	private String auth_value;
	
	@DBField(comment = "文件存在地址（本机地址：绝对路径）" , length = 200)
	private String file_path;
	
	@DBField(comment = "压缩包密码" , length = 100)
	private String zip_pwd;			//压缩包密码
	
	@DBField(comment = "排序字段，具体字段名称" , length = 100)
	private String order_field;		//排序字段,在数据库中作为排序字段，在http接口作为参数名
	
	@DBField(comment = "排序字段类型 1-数值 ， 2-时间格式" , length = 4)
	private Integer field_type;		//排序字段类型  1-数值  2-时间格式
	
	
	private String show_tagName;
	private String show_dbSourceName;
	private String show_dbType;


}
